UC-SLS Lecture 9 : Assembly : Operations and Data Types

A simple mov.S program

Setup

  • create a directory mkdir mov; cd mov

  • create and write mov.S below

  • add a Makefile to automate assembling and linking

    • we are going run the commands by hand this time to highlight the details

  • add our setup.gdb to make working in gdb easier

  • normally you would want to track everything in git

CODE: asm - mov.S

	.intel_syntax noprefix
	.text
	
	.equ EXIT_SYSCALL_NR,60
	
	.global _start
	.type _start, @function	
_start:
	mov rax, 0b1000

	mov rax, EXIT_SYSCALL_NR
	mov rdi, 2
	syscall
	
	

Assemble mov.S into mov.o directly with assembler (as)

  • -a produce listing to standard out

  • we could add -g flag to add extra debugger information but lets skip it for now

mov.o is NOT an executable

What kind of file is is it?

Examine Symbol Table

gdb -tui mov -x setup.gdb

rebuild with more debug info -g

Debug

By The Jupyter Book community
© Copyright 2021.